package com.library.dao;

import com.library.pojo.Book;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

public class BookMapperImpl implements BookMapper {
    private SqlSessionTemplate sqlSessionTemplate;

    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }

    public int addBook(Book book) {
        return sqlSessionTemplate.getMapper(BookMapper.class).addBook(book);
    }

    public int deleteBookById(int id) {
        return sqlSessionTemplate.getMapper(BookMapper.class).deleteBookById(id);
    }

    public int updateBook(Book book) {
        return sqlSessionTemplate.getMapper(BookMapper.class).updateBook(book);
    }

    public Book queryBookById(int id) {
        return sqlSessionTemplate.getMapper(BookMapper.class).queryBookById(id);
    }

    public List<Book> queryAllBook() {
        return sqlSessionTemplate.getMapper(BookMapper.class).queryAllBook();
    }

    public List<Book> queryBookByName(String name) {
        List<Book> books=sqlSessionTemplate.getMapper(BookMapper.class).queryBookByName(name);
        books.toString();
        return sqlSessionTemplate.getMapper(BookMapper.class).queryBookByName(name);
    }


}
